<?php
header('Content-type: text/javascript');
?>
jQuery(document).ready(function(){
	jQuery('.hmd_link').click(function(e){
		e.preventDefault();
		var url = encodeURIComponent(jQuery(this).attr('href'));
		url = WP_PLUGIN_URL + '/getdata.php?url=' + url;
		var index = jQuery(this).index();
		jQuery.ajax({
			'url': url,
			'cache':false,
			'dataType': 'json',
			'success':function(data){
				var html = [];
				var thumbs = data[0];
				var fulls = data[1];
				for(var i = 0, len = thumbs.length; i < len; i++){
					html.push('<a href="'+ fulls[i] +'" rel="prettyPhoto[gallery' +index+']" style="display:none;"><img src="' + thumbs[i] + '"\/></a>');
				}
				html = html.join('');
				jQuery('#hmd_image_wrapper').html(html);				
				jQuery('#hmd_image_wrapper').find('a[rel^="prettyPhoto"]').prettyPhoto({
					social_tools: false,
					autoplay_slideshow: true,
					show_title:false
				});
				jQuery.prettyPhoto.open(fulls);				
			}
		});
	});
});
